<template>
  <div class="divcont1">
    <h3>{{newsinfo.title}}</h3>
    <p class="publishtime">
      <span>发表时间：{{newsinfo.time}}</span>
      <span>点击{{newsinfo.click}}次</span>
    </p>
    <hr>
    <div v-html="newsinfo.message">

    </div>
    <!--第一步： 在父组件中向子组件传入id -->
    <newscomment :id="this.id"></newscomment>
  </div>
</template>

<script>
import newscomment from '../newsinfosubcomp/newscomment.vue'
import {Toast} from 'mint-ui'
export default {
    data(){
      return {
        id:this.$route.params.id,
        newsinfo:
          {title:"今天天气很不错，是一个值得游玩的天气",time:"2018-1-1 1:1:1",click:3,message:"嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻"},
         
        
      }
    },
    created(){
      // this.getnewsinfo()
    },
    methods:{
      getnewsinfo(){
        this.$http.get('api/io/'+this.id).then(result=>{
          if(result.body.status===0){
            this.newsinfo=result.body.message
          }else{
            Toast('获取新闻详情失败')
          }
        })
      }
    },
    components:{
      newscomment
    }
}
</script> 

<style lang="scss" scoped>
.divcont1{
  padding: 0 4px;
  h3{
    margin: 10px auto;
    text-align: center;
    color: red;
    font-size: 18px;
  }
  .publishtime{
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: blue;
    margin: 0px;
  }
}
</style>
